<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <div v-if="userRole">
        <h2 class="jh-entity-heading" data-cy="userRoleDetailsHeading"><span>UserRole</span> {{ userRole.id }}</h2>
        <dl class="row jh-entity-details">
          <dt>
            <span>Role Name</span>
          </dt>
          <dd>
            <span>{{ userRole.roleName }}</span>
          </dd>
          <dt>
            <span>Teacher</span>
          </dt>
          <dd>
            <span v-for="(teacher, i) in userRole.teachers" :key="teacher.id"
              >{{ i > 0 ? ', ' : '' }}
              <router-link :to="{ name: 'TeacherView', params: { teacherId: teacher.id } }">{{ teacher.id }}</router-link>
            </span>
          </dd>
          <dt>
            <span>Student</span>
          </dt>
          <dd>
            <span v-for="(student, i) in userRole.students" :key="student.id"
              >{{ i > 0 ? ', ' : '' }}
              <router-link :to="{ name: 'StudentView', params: { studentId: student.id } }">{{ student.id }}</router-link>
            </span>
          </dd>
        </dl>
        <button type="submit" v-on:click.prevent="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
          <font-awesome-icon icon="arrow-left"></font-awesome-icon>&nbsp;<span> Back</span>
        </button>
        <router-link v-if="userRole.id" :to="{ name: 'UserRoleEdit', params: { userRoleId: userRole.id } }" custom v-slot="{ navigate }">
          <button @click="navigate" class="btn btn-primary">
            <font-awesome-icon icon="pencil-alt"></font-awesome-icon>&nbsp;<span> Edit</span>
          </button>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script lang="ts" src="./user-role-details.component.ts"></script>
